	var details;
	unit="B7";
	function viewAccountForm(){
		$("#accountForm").html("<img src='gifs/indicator.gif' />");
		$("#accountForm").load('controllers/ViewAccountController.php?mode=1&unit_name=<?php echo $unit;?>',function(data) {
		  details=data;
		  displayAccountForm();
		});
	}
	
	function viewFinancialForm(){
		$("#financeForm").html("<img src='gifs/indicator.gif' />");
		$("#financeForm").load('controllers/ViewFinancialInformationController.php?mode=1&unit_name=<?php echo $unit;?>',function(data) {
		  details=data;
		  displayAccountForm();
		});
	}
	
	function viewAccount(){
		$("#accountForm").html("<img src='gifs/indicator.gif' />");
		$("#accountForm").load('controllers/ViewAccountController.php?mode=2&unit_name=<?php echo $unit;?>',function(data) {
		});
	}
	
	function viewFinancialInfo(){
		$("#financeForm").html("<img src='gifs/indicator.gif' />");
		$("#financeForm").load('controllers/ViewFinancialInformationController.php?mode=2&unit_name=<?php echo $unit;?>',function(data) {
		});
	}
	
	function updateAccountInfo(){
		name1=$("#name").val();
		home=$("#home_address").val();
		studnum=$("#studnum").val();
		cellnum=$("#cellnum").val();
		course=$("#course").val();
		college=$("#college").val();
		classification=$("#classification").val();
		parents=$("#parents_name").val();
		contact=$("#contact_nums").val();
		occupants=$("#other_occupants").val();
		$("#accountForm").html("<img src='gifs/indicator.gif' /><br />Updating...");
		
		$.post('controllers/UpdateAccountController.php',{
		name:name1,
		home:home,
		studnum:studnum,
		cellnum:cellnum,
		course:course,
		college:college,
		classification:classification,
		parents:parents,
		contact:contact,
		occupants:occupants,
		unitname:"<?php echo $unit;?>",
		}, function(data) {
		  viewAccount();
		  
		});
	}
	<?php if(($_SESSION['username'])=="admin"){?>
	function addpayment(){
		$("#addpaymentform").load('ajax/addpaymentform.php',function(){
		
			var units = [
			"A1","A2","A3","A4","A5","A6","A7","A8","A9",
			"B1","B2","B3","B4","B5","B6","B7","B8","B9",
			"C1","C2","C3","C4","C5","C6","C7","C8","C9",
			"D1","D2","D3","D4","D5","D6","D7","D8","D9",
			"E1","E2","E3","E4","E5","E6","E7","E8","E9",
			"F1","F2","F3","F4","F5","F6","F7","F8","F9",
			"G1","G2","G3","G4","G5","G6","G7","G8","G9",
			"H1","H2","H3","H4","H5","H6","H7","H8","H9"
			];
			$("#unit").autocomplete({
				source: units
			});
		});
		$("#addpaymentform").dialog();

	}
	function updateFinancialInfo(){
		deposit=$("#deposit").val();
		debts=$("#debts").val();
		$("#financeForm").html("<img src='gifs/indicator.gif' /><br />Updating...");
		$.post('controllers/UpdateFinancialInformationController.php',{
		deposit:deposit,
		debts:debts,
		unit_name:"<?php echo $unit;?>"
		}, function(data) {
		  viewFinancialInfo();
		 // $("#financeForm").html(data);
		//  $("#financeForm").html(data);
		});
	}
	function stopContract(){
		$("#stopcontract").html("<img src='gifs/indicator.gif' />");
		$("#stopcontract").load('controllers/StopContractController.php?unit_name=<?php echo $unit;?>',function(data) {
		});
	}
	function viewStartContractForm(){
		$("#sendContractForm").html("<img src='gifs/indicator.gif' /><br />Updating...");
		$("#sendContractForm").load('includes/startcontractform.php');
	}
	
	var details;
	unit="B7";
	function sendContractData(){
		password1=$("#password").val();
		name1=$("#name").val();
		home=$("#home_address").val();
		studnum=$("#studnum").val();
		cellnum=$("#cellnum").val();
		course=$("#course").val();
		college=$("#college").val();
		classification=$("#classification").val();
		parents=$("#parents_name").val();
		contact=$("#contact_nums").val();
		occupants=$("#other_occupants").val();
		deposit=$("#deposit").val();
		rent=$("#monthly_rent").val();
		start=$("#start_date").val();
		debts=$("#debts").val();
		$("#sendContractForm").html("");
		$("#sendContractForm").html("<img src='gifs/indicator.gif' />");
		$.post('controllers/StartContractController.php',{ 
		name: name1, 
		password: password1,
		home: home,
		studnum:studnum,
		cellnum:cellnum,
		course:course,
		college:college,
		classification: classification,
		parents:parents,
		contact:contact,
		occupants:occupants,
		deposit:deposit,
		rent:rent,
		start:start,
		debts:debts,
		unit_name:"<?php echo $unit;?>"
		}, function(data) {
		  $('#sendContractForm').html(data);
		  details=data;
			displayContractDetails();
		});		
	}
	function displayContractDetails(){
		$("#sendContractForm").html(details);
	}
	
	function viewChangePasswordForm(){
		$("#changePasswordForm").html("<img src='gifs/indicator.gif' />");
		$("#changePasswordForm").load("templates/changepassword.tpl");
	}
	function changePassword(){
		newpass= $("#new").val();
		$.post('controllers/ChangePasswordController.php?mode=2',{ 
		newpass: newpass,
		unit_name: "<?php echo $unit;?>"
		}, function(data) {
		  details=data;
			displayChangePasswordDetails();
		});
	}
	function displayChangePasswordDetails(){
		$("#changePasswordForm").html(details);
	}
	

		var details;
	function sendPayment(){
		amount=$("#amount").val();
		unit=$("#unit").val();
		mode=$("#mode").val();
		date_received=$("#date_received").val();
		receipt_no=$("#receipt_no").val();
		$("#addPaymentForm").html("<img src='gifs/indicator.gif' />");
		
		$.post('controllers/AddPaymentController.php',{
		unit: unit,
		amount: amount, 
		mode: mode, 
		date_received: date_received, 
		receipt_no: receipt_no, 
		}, function(data) {
		  details=data;
			displayPaymentDetails();
		});
	}
	function displayPaymentDetails(){
		//alert(details);
		$("#addpaymentform").html(details);
	}
	

	<?php }?>
